@()(implicit session: Session)
@config.main("Muscle") {

    <link rel="stylesheet" media="screen" href="@routes.Assets.versioned("phylotree.js-master/phylotree.css")">


    <style>

            .fa-rotate-135 {
                -webkit-transform: rotate(135deg);
                -moz-transform: rotate(135deg);
                -ms-transform: rotate(135deg);
                -o-transform: rotate(135deg);
                transform: rotate(135deg);
            }

            .fa-rotate-45 {
                -webkit-transform: rotate(45deg);
                -moz-transform: rotate(45deg);
                -ms-transform: rotate(45deg);
                -o-transform: rotate(45deg);
                transform: rotate(45deg);
            }

            .myGroup {
                margin-top: 15px;
                margin-left: 15px;
            }

            .exmaple:hover{
                cursor: pointer;
            }

    </style>

    <div class="body-box">
        <div class="page-box">

            @config.subTitle("Muscle",detail = " 	MUSCLE is one of the best-performing multiple alignment programs according to published benchmark tests, with accuracy and speed that are consistently better than CLUSTALW. MUSCLE can align hundreds of sequences in seconds. Most users learn everything they need to know about MUSCLE in a few minutes—only a handful of command-line options are needed to perform common alignment tasks.")

            <div class="main-body">

                <form class="registration-form col-sm-12 my-form" id="form">

                    <div class="row">

                        @components.radio("Type of query", "method", "text", Seq(("text", "Text"), ("file", "File")), "ChangeMethod()", labelBox = "3")

                        @components.textarea("Enter FASTA sequences", "queryText", "queryText", "getExample()",boxId = "text",placeholder="Paste DNA query sequence(s) here.")

                        @components.file("Upload file","file","muscle",boxId = "fileBox")

                        @components.radio("Output Tree", "tree", "none", Seq(("none", "none"), ("tree1", "From first iteration"),
                            ("tree2", "From second iteration")), labelBox = "3")

                    </div>

                    <div class="col-md-12 form-group">
                        <label class="col-sm-3"></label>
                        <button type="button" class="btn my-btn" style="width: 200px" onclick="Search()">
                            Run</button>
                    </div>
                </form>

                <div id="result" style="display: none;">
                    <hr/>
                    <h5>Fasta result:
                        &nbsp;<button class="btn my-btn" onclick="downloadFasta()"><i class="fa fa-download"></i>&nbsp;Download</button>
                    </h5>
                    <pre id="out" style="background-color: white"></pre>
                    <h5>MSF result:
                        &nbsp;<button class="btn my-btn" onclick="downloadMSF()"><i class="fa fa-download"></i>&nbsp;Download</button>
                    </h5>
                    <pre id="msf" style="background-color: white"></pre>
                    <h5>PHYLIP result:
                        &nbsp;<button class="btn my-btn" onclick="downloadPHYLIP()"><i class="fa fa-download"></i>&nbsp;Download</button>
                    </h5>
                    <pre id="phys" style="background-color: white"></pre>
                    <div id="treeContent">
                        <h5>Tree result:
                            &nbsp;<button class="btn my-btn" onclick="downloadTree()"><i class="fa fa-download"></i>&nbsp;Download</button>
                        </h5>
                        <pre id="treeOut" style="background-color: white"></pre>
                        <h5>Tree plot:
                            <form action="/PODB/tools/downloadTree" method="post" onsubmit="mySubmit()" style="display: inline">
                                <input type="hidden" name="svgHtml" id="svgHtml">
                                    &nbsp;<button class="btn my-btn" type="submit"><i class="fa fa-download"></i>&nbsp;Download</button>
                            </form>
                        </h5>
                        <div style="border: 1px solid #ccc;">
                            <div>
                                <div class="btn-group myGroup">
                                    <button type="button" class="btn btn-default btn-sm" data-direction="vertical" data-amount="1" title="Expand vertical spacing">
                                        <i class="fa fa-arrows-v"></i>
                                    </button>
                                    <button type="button" class="btn btn-default btn-sm" data-direction="vertical" data-amount="-1" title="Compress vertical spacing">
                                        <i class="fa  fa-compress fa-rotate-135"></i>
                                    </button>
                                    <button id="leftRight" type="button" class="btn btn-default btn-sm" data-direction="horizontal" data-amount="1" title="Expand horizonal spacing">
                                        <i class="fa fa-arrows-h"></i>
                                    </button>
                                    <button type="button" class="btn btn-default btn-sm" data-direction="horizontal" data-amount="-1" title="Compress horizonal spacing">
                                        <i class="fa  fa-compress fa-rotate-45"></i>
                                    </button>
                                    <button type="button" class="btn btn-default btn-sm" id="sort_ascending" title="Sort deepest clades to the bototm">
                                        <i class="fa fa-sort-amount-asc"></i>
                                    </button>
                                    <button type="button" class="btn btn-default btn-sm" id="sort_descending" title="Sort deepsest clades to the top">
                                        <i class="fa fa-sort-amount-desc"></i>
                                    </button>
                                    <button type="button" class="btn btn-default btn-sm" id="sort_original" title="Restore original order">
                                        <i class="fa fa-sort"></i>
                                    </button>
                                </div>
                                <div class="btn-group myGroup" data-toggle="buttons">

                                    <label class="btn btn-default btn-sm active" id="linear">
                                        <input name="options" class="phylotree-layout-mode" data-mode="linear" autocomplete="off" checked="" title="Layout left-to-right" type="radio">
                                        Linear
                                    </label>
                                    <label class="btn btn-default  btn-sm">
                                        <input name="options" class="phylotree-layout-mode" data-mode="radial" autocomplete="off" title="Layout radially" type="radio">
                                        Radial
                                    </label>
                                </div>
                                <div class="btn-group myGroup" data-toggle="buttons">
                                    <label class="btn btn-default active btn-sm" id="defaultAlign">
                                        <input class="phylotree-align-toggler" data-align="left" name="options-align" autocomplete="off" checked="" title="Align tips labels to branches" type="radio">
                                        <i class="fa fa-align-left"></i>
                                    </label>
                                    <label class="btn btn-default btn-sm">
                                        <input class="phylotree-align-toggler" data-align="right" name="options-align" autocomplete="off" title="Align tips labels to the edge of the plot" type="radio">
                                        <i class="fa fa-align-right"></i>

                                    </label>
                                </div>
                            </div>

                            <svg id="tree_display" xmlns='http://www.w3.org/2000/svg' xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <script src="@routes.Assets.versioned("phylotree.js-master/d3.js")" type="text/javascript"></script>
    <script src="@routes.Assets.versioned("phylotree.js-master/phylotree.js")" type="text/javascript"></script>
    <script src="@routes.Assets.versioned("phylotree.js-master/underscore.min.js")" type="text/javascript"></script>
    <script type="text/javascript" src="@routes.Assets.versioned("phylotree.js-master/vis.min.js")"></script>
    <script src="@routes.Assets.versioned("blast/js/FileSaver.min.js")" type="text/javascript"></script>

    <script>

            $(function () {
                $("#sort_original").on("click", function (e) {
                    tree.resort_children(function (a, b) {
                        return a["original_child_order"] - b["original_child_order"];
                    });
                });

                $("#sort_ascending").on("click", function (e) {
                    sort_nodes(true);
                });

                $("#sort_descending").on("click", function (e) {
                    sort_nodes(false);
                });

                $(".phylotree-layout-mode").on("change", function (e) {
                    if ($(this).is(':checked')) {
                        if (tree.radial() != ($(this).data("mode") == "radial")) {
                            tree.radial(!tree.radial()).placenodes().update();
                        }
                    }
                });

                $("[data-direction]").on("click", function (e) {
                    var which_function = $(this).data("direction") === 'vertical' ? tree.spacing_x : tree.spacing_y;
                    which_function(which_function() + (+$(this).data("amount"))).update();
                });

                $(".phylotree-align-toggler").on("change", function (e) {
                    if ($(this).is(':checked')) {
                        if (tree.align_tips($(this).data("align") === "right")) {
                            tree.placenodes().update();
                        }
                    }
                });
                ChangeMethod()
                formValidation()
                $("#file").fileinput();
            })

            var tree;
            var eg;

            function downloadFasta() {
                var fileName = "result.fa";
                var content = $("#out").text();
                var blob = new Blob([content], {
                    type: "text/plain;charset=utf-8"
                });
                saveAs(blob, fileName)
            }

            function downloadMSF() {
                var fileName = "result.msf";
                var content = $("#msf").text();
                var blob = new Blob([content], {
                    type: "text/plain;charset=utf-8"
                });
                saveAs(blob, fileName)
            }

            function downloadPHYLIP() {
                var fileName = "result.phys";
                var content = $("#phys").text();
                var blob = new Blob([content], {
                    type: "text/plain;charset=utf-8"
                });
                saveAs(blob, fileName)
            }

            function downloadTree() {
                var fileName = "newick.txt";
                var content = $("#treeOut").text();
                var blob = new Blob([content], {
                    type: "text/plain;charset=utf-8"
                });
                saveAs(blob, fileName)
            }

            function mySubmit() {
                var html = $("svg:first").prop("outerHTML");
                $("#svgHtml").val(html);
                return true
            }

            function sort_nodes(asc) {
                tree.traverse_and_compute(function (n) {
                    var d = 1;
                    if (n.children && n.children.length) {
                        d += d3.max(n.children, function (d) {
                            return d["count_depth"];
                        });
                    }
                    n["count_depth"] = d;
                });
                tree.resort_children(function (a, b) {
                    return (a["count_depth"] - b["count_depth"]) * (asc ? 1 : -1);
                });
            }


            function Search() {
                let form = $("#form");
                let fv = form.data("formValidation");
                fv.validate();
                if (fv.isValid()) {
                    let index = MyTable.prototype.runningIcon();
                    $.ajax({
                        url: "@routes.ToolsController.toolsFileRun("muscle")",
                        type: "post",
                        processData: false,
                        contentType: false,
                        data: new FormData(form[0]),
                      //  async: false,
                        success: function (data) {
                            layer.close(index);

                            if (data.valid === "false") {
                                swal("Error", data.message, "error");
                                $("#result").hide()
                            } else {

                                $("#out").html(data.out);
                                $("#msf").html(data.msf);
                                $("#phys").html(data.phys);
                                if (data.tree === "") {
                                    $("#treeContent").hide()
                                } else {
                                    $("label").removeClass("active");
                                    $("#defaultAlign,#linear").addClass("active");
                                    $("#treeOut").html(data.tree);
                                    var example_tree = data.tree;
                                    tree = d3.layout.phylotree()
                                            .svg(d3.select("#tree_display")).radial(false);
                                    tree.spacing_x(75, true);
                                    tree.spacing_y(100, true);
                                    tree(example_tree)
                                            .layout();
                                    $("#treeContent").show()
                                }

                                let $result = $("#result")

                                $result.show();
                                let target_top = $result.offset().top ;
                                $("html,body").animate({scrollTop: target_top}, 800);
                            }
                        }
                    });
                }
            }

            function ChangeMethod() {
                let value = $("input[name=method]:checked").val()
                if (value === "text") {
                    $("#text").show()
                    $("#fileBox").hide()
                } else {
                    $("#fileBox").show()
                    $("#text").hide()
                }
            }

            function getExample() {
                let seq = ">NC_007683_Fucus_vesiculosus\n" +
                        "MSFTQDLKPSWQTFFPSVFSSSLSGFFTRWFFSTNHKDIGTLYLLFGAFSGVLGTAMSVLIRLQLATPGNMFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMSMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILGTFSRKPIFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFAIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLAYPEILGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNGIASFGSILSSVASLFFFYVVYLTLTQGSIEEANPWVKNRGLAFPLLPRKTSGSSQY\n" +
                        ">NC_033408_Sargassum_aquifolium\n" +
                        "MSFTQESKPLWQSFIPLISNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLSSPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHSEDSNPWVENRGVAFPVIESKNR\n" +
                        ">KY084910_Sargassum_fluitans\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASXXXXXXXXXXXXXXYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_033385_Sargassum_fluitans\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_024655_Sargassum_fusiforme\n" +
                        "MSFTQESKPLWQSFIPLVSSSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLAGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWVATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWVGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYIVYLTLTEGYPEDSNPWVKDRGVAFPAIESKSG\n" +
                        ">NC_024861_Sargassum_hemiphyllum\n" +
                        "MSFTPESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLMLLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWVGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYIVYLTLTEGHLEESNPWVKNRGIAFPTIESKSR\n" +
                        ">NC_024613_Sargassum_horneri\n" +
                        "MSFTQESKPSWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNLFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYIVYLTLTKGHIEDSNPWVKGRGVAFPMIESKVG\n" +
                        ">KT272403_Sargassum_ilicifolium\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNMFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGRLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_024614_Sargassum_muticum\n" +
                        "MSFTQESKPSWQSFIPLVSSSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLMLLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWVGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLLFFYIVYLTLTEGHLEESNPWVKDRGIAFPTIESKSG\n" +
                        ">KY084908_Sargassum_natans\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">KY084911_Sargassum_natans\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">KY084912_Sargassum_natans\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_033384_Sargassum_natans\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">KT280278_Sargassum_polycystum\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNMFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_034272_Sargassum_spinuligerum\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_026700_Sargassum_thunbergii\n" +
                        "MSFTQESKPSWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWVGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYIVYLTLTEGPIEDSNPWVKGRGIAFPAIESKSG\n" +
                        ">NC_027508_Sargassum_vachellianum\n" +
                        "MSFTQESKPLWQSFIPLVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNTFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWIGKMTGLGYPEVLGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSVASFGSILSSVASLFFFYVVYLTLTQGHLEDSNPWVENRGVAFPVIQSKKR\n" +
                        ">NC_027413_Turbinaria_ornata\n" +
                        "MSFTQESKPSWQSFIPSVSNSALSGFFTRWFFSTNHKDIGTLYLIFGAFSGVLGTAMSVLIRLQLASPGNMFLGGNYQLYNVIVTAHAFLMIFFMVMPVLIGGFGNWFVPLMIGAPDMAFPRMNNISFWLLPPSLILLLASSLVEAGAGTGWTVYPPLSGIQAHSGPSVDLAIFSLHLSGAASILGAINFITTIFNMRAPGMGMHRLPLFVWSVLITAFLLLLSLPVLAGGITMLLTDRNFNTTFFDPAGGGDPVLYQHLFWFFGHPEVYILILPGFGIVSHILATFSRKPVFGYLGMVYAMLSIGILGFIVWAHHMFTVGLDIDTRAYFTAATMIIAVPTGIKIFSWIATMWGGSIRLKTPMLFSIGFLFLFTIGGLTGVVLANSGVDIALHDTYYVVAHFHYVLSMGAAFTMFGAFYFWVGKMTGLGYPEILGQIHFWLMFIGVNLTFFPMHFLGLAGMPRRIPDYPDSYAGWNSIASFGSILSSVASLFFFYVVYLTLTQGHSEDANPWVKDRGLAFPAIQSKSV\n"

                $("#queryText").val(seq)
            }

            function formValidation() {
                $('#form').formValidation({
                    framework: 'bootstrap',
                    icon: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        queryText: {
                            validators: {
                                notEmpty: {
                                    message: 'FASTA sequences is required！'
                                },
                            regexp: {
                                regexp: /^(>.*\n[a-zA-Z\n]+\s*){2,}$/,
                                message: "Sequences is invalid(at least two sequences)!"
                            }
                            }
                        },
                        file: {
                            validators: {
                                notEmpty: {
                                    message: "Query fasta is required!"
                                },
                                file: {
                                    extension: 'fa,fasta',
                                    message: 'Query fasta file must be fasta file ！'
                                }
                            }
                        }
                    }
                });
            }


    </script>
}